<?
require_once("admin/dbconnect.php");
require_once("admin/classes/customer.php");

session_start(); 
if(isset($_SESSION['ep_customer_id']))
{
	header("location:myaccount.php");
}
if($_REQUEST['submit'] != ""){
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];

	$str="select count(*) from customer where email='$username' and status ='Y'";

		$rc = mysql_query($str) or die ("Sorry! could not execute query $str ".mysql_error());
		$count=mysql_fetch_row($rc);

		if($count[0]<1)
		{
			$mesg="<center>Invalid Username try again!</center>";
			header("location:register.php");
		}
		else
		{
			$stra="select email, name, customer_id, password as pwd, surname, paid from customer where email='$username'";
			$rca = mysql_query($stra) or die ("Sorry! could not execute query $str ".mysql_error());

					$a_row=mysql_fetch_array($rca);

					$username=$a_row['email'];
					$customer_id=$a_row['customer_id'];
					$checkPassword=$a_row['pwd'];
					$newpassword=$password;


				if($newpassword == $checkPassword)
				{		
						/*setcookie("ep_customer_id", $customer_id, time()+3600, "/","", 0);
						setcookie("ep_customername", "$username", time()+3600, "/","", 0);
						setcookie("ep_customer_name", $a_row['name'], time()+3600, "/","", 0);
						setcookie("ep_email", $a_row['email'], time()+3600, "/","", 0);
						setcookie("paid_customer_status", $a_row['paid'], time()+3600, "/","", 0); */
						
						session_start();						

						/*session_start(); // start up your PHP session! 
						session_register ("ep_customer_id");	// Create a session variable called ep_customer_id
						session_register ("ep_customername");	// Create a session variable called ep_customername
						session_register ("ep_customer_name");	// Create a session variable called ep_customer_id
						session_register ("ep_email");	// Create a session variable called ep_customername
						
						$HTTP_SESSION_VARS ["ep_customer_id"] = "work"	// Set name = form variable $name
						$HTTP_SESSION_VARS ["ep_customername"] = "work" // Set job = form variable $ep_customername						
						$HTTP_SESSION_VARS ["ep_customer_name"] = "work"	// Set name = form variable $name
						$HTTP_SESSION_VARS ["ep_email"] = "work"	// Set job = form variable $ep_customername						*/
						
						$_SESSION['ep_customer_id'] = $customer_id;
						$_SESSION['ep_customername'] = $username;
						$_SESSION['ep_customer_name'] = $a_row['name'];
						$_SESSION['ep_email'] = $a_row['email'];
						$_SESSION['paid_customer_status'] = $a_row['paid']; 

					//customer online code here
					$online ="update customer set online = now() , online_status ='online' where email='$username'";
					$rsb = mysql_query($online);
					//online customer code ends here

						if($_SESSION['gbl_from_art']!=""){
							$tmp_var_5=$_SESSION['gbl_from_art'];						
							unset($_SESSION['gbl_from_art']);
							header("Location:articles/article_comment.php?art=".$tmp_var_5);
							exit;
							//code end purab 14 jun 2007
						}else if($_SESSION['gbl_from_community1']=="Y"){
							unset($_SESSION['gbl_from_community1']);
							header("Location:articles/mod_articles.php");
							exit;
						} else if($flg=="NEW"){
							header("Location:myaccount.php?flg=1");
						} else {
							header("Location:myaccount.php");
						}
						
						
						
				} else {
						$mesg="<center>Password is not matching! Try again!</center>";
						header("location:register.php");
				}
		}
		return $mesg;


}
?>

<?php require_once('include/header.php'); ?>



      <div id="middle_container_for_innerpage">
      <div id="innerpage_top_image"><img src="images/images/innerpage_top_corner_820x5.jpg"  height="5" /></div> 
      <div id="middle_inner_container">
      <?php require_once('include/left_menu.php'); ?>
        
        <div id="inner_page_middle_data">
			<div id="page_heading">Login to eParinay.com</div>
            <div id="login_row" style="height:1px;">
   			
        		
            </div>
            <div id="login_form_and_info_container">
				<div id="padding_use_only" style="width:250px; padding-left:155px;">
                <div id="login_form_container">
                  <form action="" method="POST" name="login" class="form-text" id="login">
				  <? if($mesg){ ?><div id="login_row" style="width:227px;">
                      <div id="login_form_text"></div>
                            <div id="login_form_field"><?=$mesg?></div>
				  </div><? } ?>
                    <div id="login_row" style="width:227px;">
                      <div id="login_form_text">Email ID:</div>
                            <div id="login_form_field"><input name="username" type="text" class="textfield" id="username" style="width:240px;" /></div>
                    </div>
                        <div id="login_row" style="width:227px;">
                          <div id="login_form_text">Password:</div>
                            <div id="login_form_field"><input name="password" type="password" class="textfield" id="password" style="width:240px;" /></div>
                    </div>
                        <div id="login_row" style="width:227px;">
                          <div id="login_form_text">&nbsp;</div>
                            <div id="login_form_field"><div id="button_border">
              <input name="submit" type="submit" class="button" id="submit" value="Login" onClick="return chklogin()" />
                    </div>
                          </div>
                    </div>
                  </form>
                </div>
			  </div>
                <div id="login_row" style="width:490px; padding-top:5px; text-align: right;"><a href="forgot_password.php">Forgot Password?</a></div>
                <div id="login_not_a_member">
                    <p>Not Yet a Member? <a href="register.php" class="FormHeads">Join   Now!</a></p>
                  <p>Registration with eParinay.com will provide you with the following privileges:</p>
                    <p>1. View Profiles (Free), 2. Contact Profiles, 3. Upload Photo, 4. Privacy Assured, 5. Edit Profile, 6. Send messages (Free), 7. Online or Offline, 8. Change Password</p>
                    <p></p>
                    <p></p>
                </div>
            </div>
			<div id="login_row"></div>
        </div>
        

       
       
      </div> 
      <div id="corner_container_bottom_for_innerpage"><img src="images/images/innerpage_bottom_corner_820x10.jpg"  height="10" /></div>
    </div> 
      <!-- middle_container ends -->
    
    
        
    
<?php require_once('include/footer.php'); ?>
